import React from "react"
import {getnow} from "./api"
import "./list.css"
class Now extends React.Component{
    constructor(){
        super()
        this.state={
            data:[],
        }
    }
    ren(){
        this.props.history.go(-1)
    }
    tiao(id){
        this.props.history.push(`/my/now/plays?id=${id}`)
    }
    componentDidMount(){
        let uid = localStorage.getItem("uid")
        console.log(uid)
        getnow(uid)
        .then(res=>{
            console.log(res)
            this.setState({
                data:res.weekData
            })
        })
    }
    render(){
        let {data} = this.state
        return(
            <div id="list">
                <h3 onClick={this.ren.bind(this)}>
                <img src={require('../../imgs/back.png')}/>
                    返回</h3>
                <div id="list2">
                    <ul>
                        {data.map(item=><li key={item.id} onClick={this.tiao.bind(this,item.song.id)}>{item.song.name}</li>)}
                    </ul>
                </div>
            </div>
        )
    }
}


export default Now